<?xml version='1.0'?>

<!--
Copyright (C) 2006, Stefano Zacchiroli <zack@bononia.it>

This is free software, you can redistribute it and/or modify it under the terms
of the GNU General Public License version 2 as published by the Free Software
Foundation.

Based on the XSLT stylesheet by Sebastian Menge, posted on the tomboy-list (see
http://beatniksoftware.com/pipermail/tomboy-list_beatniksoftware.com/2006-February/001068.html)
-->

<xsl:stylesheet
  xmlns:link="http://beatniksoftware.com/tomboy/link"
  xmlns:size="http://beatniksoftware.com/tomboy/size"
  xmlns:tomboy="http://beatniksoftware.com/tomboy"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version='1.0'
>

<xsl:output method="text" />
<xsl:param name="root-note" />
<xsl:param name="export-linked" />


<xsl:template name="title">
  <xsl:text>"</xsl:text>
  <xsl:value-of select="/tomboy:note/tomboy:title" />
  <xsl:text>"</xsl:text>
</xsl:template>

<xsl:template match="/">
  <xsl:text>digraph tomboy {
  </xsl:text>
  <xsl:apply-templates select="tomboy:note" />
  <xsl:text>}</xsl:text>
</xsl:template>

<xsl:template match="tomboy:note">
	<xsl:apply-templates select="tomboy:text" />
</xsl:template>

<xsl:template match="tomboy:text">
<xsl:call-template name="title" />
  <xsl:text> [shape=box];
</xsl:text>
  <xsl:apply-templates select="node()"/>

  <xsl:if test="/tomboy:note/tomboy:title = $root-note">
    <xsl:if test="$export-linked">
    <xsl:apply-templates select="document(.//link:internal/text())/node()" />
    </xsl:if>
  </xsl:if>
</xsl:template>

<xsl:template match="tomboy:note-content">
  <xsl:apply-templates select="link:internal" />
  <xsl:apply-templates select="link:url" />
  <xsl:apply-templates select="link:broken" />
</xsl:template>

<xsl:template match="link:broken">
  <xsl:call-template name="title" />
  <xsl:text> -&gt; </xsl:text>
  <xsl:value-of select="current()"/>
  <xsl:text> [color=red];
</xsl:text>
</xsl:template>

<xsl:template match="link:url">
<!-- uncomment this if you want links to URLs to appear in the mindmap -->
<!--
  <xsl:call-template name="title" />
  <xsl:text> -&gt; &quot;</xsl:text>
  <xsl:value-of select="current()"/>
  <xsl:text>&quot;</xsl:text>
  <xsl:text> [color=blue];
</xsl:text>
-->
</xsl:template>

<xsl:template match="link:internal">
  <xsl:call-template name="title" />
  <xsl:text> -&gt; "</xsl:text>
  <xsl:value-of select="current()"/>
  <xsl:text>";
</xsl:text>
</xsl:template>

</xsl:stylesheet>

